﻿using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.SpecialUtils.View;
using PictureCompression.UserUtils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace PictureCompression
{
    public partial class MainView : Form
    {
        public MainView()
        {
            InitializeComponent();
            InitView();
        }

        private void InitView()
        {
            new ViewInfoMemory().InitTextboxSaveInfo(TbImageSize);
        }

        private void BtSelectFile_Click(object sender, EventArgs e)
        {
            UserImageHelper.SaveFileBatch(FileHelper.SelectMultiFile(), TbImageSize.Text, TbNewFloderName.Text);
        }

        private void MainView_DragDrop(object sender, DragEventArgs e)
        {
            string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            foreach (var item in s)
            {
                Console.WriteLine(item);
                UserImageHelper.SaveFile(item, TbImageSize.Text, TbNewFloderName.Text);
            }
        }

        private void MainView_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))//判断是否是文件，如果是，则接受全部数据
            {
                e.Effect = DragDropEffects.All;
            }
            else
            {
                e.Effect = DragDropEffects.None;//拒绝接受数据
            }
        }

        private void TbImageSize_TextChanged(object sender, EventArgs e)
        {
            new ViewInfoMemory().SaveTextboxInfo(TbImageSize);
        }
    }
}